home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / EPISODE / JKM_PCG.GOO / cog_00_singlecam.cog next >
Text File  |  1998-02-25  |  6KB  |  281 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # 00_SINGLECAM.COG
  4. #
  5. # Multiple cameras cog.
  6. # These cameras are designed to be used in single player,
  7. # and they can be destroyed.
  8. #
  9. # [YB]
  10. #
  11. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  12.  
  13. symbols
  14.  
  15. surface     ViewSwitch
  16. surface     ScreenTrigger
  17.  
  18. thing       disabledCamera                   nolink
  19.  
  20. thing       camera                           nolink
  21. thing       camera1                          nolink
  22. thing       camera2                          nolink
  23. thing       camera3                          nolink
  24. thing       camera4                          nolink
  25. thing       camera5                          nolink
  26. thing       camera6                          nolink
  27. thing       camera7                          nolink
  28. thing       camera8                          nolink
  29. thing       camera9                          nolink
  30. thing       camera10                         nolink
  31.  
  32. int         numCameras
  33.  
  34. flex        minChangeRate=0.5
  35.  
  36. int         player                           local
  37. int         active=0                         local
  38. int         activeCam=-1                     local
  39. int         old_camera                       local
  40. int         allowChangeCam=1                 local
  41.  
  42. int         startHealth=0.0                  local
  43. vector      startPosition                    local
  44.  
  45. int         triggerSource                    local
  46. int         dummy                            local
  47.  
  48. #sound       SwitchOnSound=activate02.wav     local
  49. sound       SwitchOffSound=deactivate02.wav  local
  50. sound       camChangeSnd=beep2.wav           local
  51.  
  52. message     startup
  53. message     activated
  54. message     playeraction
  55. message     pulse
  56. message     timer
  57. message     trigger
  58.  
  59. end
  60.  
  61. # ========================================================================================
  62.  
  63. code
  64.  
  65. startup:
  66.    player = GetLocalPlayerThing();
  67.    SetWallCel(ViewSwitch, 0);
  68.    Return;
  69.  
  70. # ........................................................................................
  71.  
  72. activated:
  73.  
  74.    // Do not allow to activate the camera with the scope on...
  75.    if(GetCurWeapon(player) == 13) Return;
  76.  
  77.    if(active) Return;
  78.  
  79.    active = 1;
  80.  
  81.    SetActorFlags(player, 0x80800000);
  82.  
  83.    StopThing(player);
  84.    SetActionCog(GetSelfCog(), 0x7FFFFFFF);
  85.  
  86.    startHealth = GetThingHealth(player);
  87.    startPosition = GetThingPos(player);
  88.  
  89.    SetPulse(0.5);
  90.  
  91.    SetWallCel(ViewSwitch, 1);
  92.    // dummy = PlaySoundLocal(SwitchOnSound, 1.0, 0.0, 0);
  93.  
  94.    old_camera = GetCurrentCamera();
  95.    SetCurrentCamera(0);
  96.  
  97.    call next_cam;
  98.  
  99.    Return;
  100.  
  101. # ........................................................................................
  102.  
  103. playeraction:
  104.    if (GetParam(0) == 0.0)             // Jump
  105.    {
  106.       if (GetParam(2) != 0.0) call prev_cam;
  107.       ReturnEx(0.0);
  108.    }
  109.    else
  110.    if (GetParam(0) == 1.0)             // Crouch
  111.    {
  112.       if (GetParam(2) != 0.0) call next_cam;
  113.       ReturnEx(0.0);
  114.    }
  115.    else
  116.    if (GetParam(0) == 2.0)             // Activated
  117.    {
  118.       call stop_cam;
  119.       ReturnEx(0.0);
  120.    }
  121.    else
  122.    if (GetParam(0) == 3.0)             // Fire
  123.    {
  124.       // Allow the player to fire...
  125.       ReturnEx(1.0);
  126.    }
  127.    else
  128.    if (GetParam(0) == 4.0)             // Strafe
  129.    {
  130.       if(GetParam(2) > 0)
  131.          call next_cam;
  132.       else
  133.          call prev_cam;
  134.  
  135.       ReturnEx(0.0);
  136.    }
  137.    else
  138.    if (GetParam(0) == 5.0)             // Turn
  139.    {
  140.       if(GetParam(2) < 0)
  141.          call next_cam;
  142.       else
  143.          call prev_cam;
  144.  
  145.       ReturnEx(0.0);
  146.    }
  147.    else
  148.    if (GetParam(0) == 14.0)         // Other Actions
  149.    {
  150.       if (GetParam(2) == 0.0)    // Cycle Camera
  151.       {
  152.          if (GetCurrentCamera() == 0)
  153.          {
  154.             // We're in first person mode.
  155.          }
  156.          else
  157.          {
  158.             // We're in third person mode.
  159.          }
  160.       }
  161.       ReturnEx(1.0);
  162.    }
  163.    else
  164.    {
  165.       ReturnEx(0.0);
  166.    }
  167.  
  168.    Return;
  169.  
  170. # ........................................................................................
  171.  
  172. pulse:
  173.    SetPulse(0.5);
  174.  
  175.    // check that the player didn't die
  176.    if(GetThingHealth(player) < 1)
  177.    {
  178.       call stop_cam;
  179.       Return;
  180.    }
  181.  
  182.    // If he took damage to health stop the camera
  183.    if(GetThingHealth(player) < startHealth)
  184.    {
  185.       call stop_cam;
  186.       Return;
  187.    }
  188.  
  189.    // If he changed position (blown by explosion, pushed, ...) stop the camera
  190.       if(!VectorEqual(startPosition, GetThingPos(player)))
  191.    {
  192.       call stop_cam;
  193.       Return;
  194.    }
  195.  
  196.    Return;
  197.  
  198. # ........................................................................................
  199.  
  200. timer:
  201.    allowChangeCam = 1;
  202.    Return;
  203.  
  204. # ........................................................................................
  205.  
  206. next_cam:
  207.    if(!allowChangeCam) Return;
  208.  
  209.    activeCam = activeCam + 1;
  210.    if(activeCam >= numCameras) activeCam = 0;
  211.    call switch_cam;
  212.    Return;
  213.  
  214. prev_cam:
  215.    if(!allowChangeCam) Return;
  216.  
  217.    activeCam = activeCam - 1;
  218.    if(activeCam < 0) activeCam = numCameras - 1;
  219.    call switch_cam;
  220.    Return;
  221.  
  222. switch_cam:
  223.    Print(" ");
  224.    Print(" ");
  225.    Print(" ");
  226.    Print(" ");
  227.    Print(" ");
  228.    jkStringClear();
  229.    jkStringConcatUNIString(365);
  230.    jkStringConcatFormattedInt(activeCam, "%d ");
  231.    jkStringOutput(-1, -1);
  232.  
  233.    dummy = PlaySoundLocal(camChangeSnd, 1.0, 0.0, 0);
  234.  
  235.    SetCameraFocus(0, camera[activeCam]);
  236.    allowChangeCam = 0;
  237.    SetTimerEx(minChangeRate, 1, 0, 0);
  238.    Return;
  239.  
  240. stop_cam:
  241.    if(active)
  242.    {
  243.       SetCameraFocus(0, player);
  244.       SetCurrentCamera(old_camera);
  245.    }
  246.  
  247.    SetPulse(0);
  248.    active = 0;
  249.  
  250.    SetWallCel(ViewSwitch,0);
  251.    dummy = PlaySoundLocal(SwitchOffSound, 1.0, 0.0, 0);
  252.  
  253.    // Turn off control capture.
  254.    SetActionCog(-1, 0);
  255.  
  256.    ClearActorFlags(player, 0x80800000);
  257.  
  258.    Print(" ");
  259.    Print(" ");
  260.    Print(" ");
  261.    Print(" ");
  262.    Print(" ");
  263.  
  264.    Return;
  265.  
  266. # ........................................................................................
  267.  
  268. trigger:
  269.    triggerSource = GetSourceRef();
  270.  
  271.    // Handle only the cameras range
  272.    if((triggerSource < 10023) || (triggerSource > 10033)) Return;
  273.  
  274.    camera[triggerSource - 10023] = disabledCamera;
  275.  
  276.    Return;
  277.  
  278. end
  279.  
  280.  
  281.